<template>
  <el-aside :width="iscollapse ? '64px' : '200px'" class="layout-left">
    <h2 class="title">
      <div v-if="iscollapse">
        <i class="el-icon-monitor"></i>
      </div>
      <div v-else>
        <h3>后台管理系统</h3>
      </div>
    </h2>
    <!-- 左侧导航 -->
    <el-menu
      default-active="2"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose"
      background-color="#20222a"
      text-color="#fff"
      active-text-color="#f60"
      unique-opened
      router
      :collapse="iscollapse"
    >
      <el-menu-item index="/admin">
        <i class="el-icon-s-home"></i>
        <span slot="title">首页</span>
      </el-menu-item>
      <el-submenu
        :index="String(index)"
        :key="item.id"
        v-for="(item, index) in getMenus"
      >
        <template slot="title">
          <i :class="item.icon"></i>
          <span>{{ item.title }}</span>
        </template>
        <el-menu-item-group>
          <el-menu-item :index="v.url" :key="v.id" v-for="v in item.children">{{
            v.title
          }}</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </el-aside>
</template>

<script>
import { mapState, mapGetters } from "vuex";
export default {
  name: "",
  data() {
    return {};
  },
  created() {},
  updated() {},
  mounted() {},
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
  },
  computed: {
    ...mapState(["iscollapse"]),
    ...mapGetters(["getMenus"]),
  },
};
</script>

<style  scoped>
.el-menu {
  border-right: none;
}
/* .el-aside {
  transition: all 0.3s;
} */
.layout-left {
  overflow-x: hidden;
  background: #20222a;
  color: #fff;
  font-size: 14px;
  transition: width 300ms;
}
.title {
  text-align: center;
  line-height: 60px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.mini {
  font-size: 12px;
  /* display: none; */
}
.big {
  font-size: 18px;
}
</style>
